package com.qhong.config;


import com.qhong.modules.entity.TestUserInfo;
import org.modelmapper.ModelMapper;
import org.modelmapper.config.Configuration.AccessLevel;
import org.modelmapper.convention.MatchingStrategies;
import org.modelmapper.convention.NamingConventions;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Created by qhong on 2018/6/13 13:48
 **/
@Configuration
public class BeanConfig {

	/**
	 * http://modelmapper.org/user-manual/configuration/
	 * @return
	 */
	@Bean
	public ModelMapper getModelMapper(){
		ModelMapper modelMapper=new ModelMapper();
		modelMapper.getConfiguration()
				.setFieldMatchingEnabled(false)
				//匹配私有字段
				.setFieldAccessLevel(AccessLevel.PRIVATE)
				//松散的匹配源和目标属性
				//.setMatchingStrategy(MatchingStrategies.LOOSE)
				//严格的匹配源和目标属性
				.setMatchingStrategy(MatchingStrategies.STRICT)
				//代表没有命名约定,这适用于所有属性名
				.setSourceNamingConvention(NamingConventions.NONE)
				.setDestinationNamingConvention(NamingConventions.NONE);
		return modelMapper;
	}

	@Bean
	public TestUserInfo getTestUserInfo(){
		TestUserInfo info=new TestUserInfo();
		info.setId(1L);
		info.setName("hongda");
		return info;
	}
}
